package com.gavin.lingxi.rtclib;


import org.webrtc.PeerConnection;

import java.util.List;

public class Options {

    public final boolean initiator;
    public final boolean videoEnable;
    public final boolean audioEnable;
    public final String Uid;
    public final IAppRTCClient.SignalingParameters signalingParameters;
    public final IRTCMsgClient rtcMsgClient;

    private Options(boolean initiator, boolean videoEnable, boolean audioEnable, String uid,
                    List<PeerConnection.IceServer> iceServerList, IRTCMsgClient rtcMsgClient){
        this.initiator = initiator;
        this.videoEnable = videoEnable;
        this.audioEnable = audioEnable;
        this.rtcMsgClient = rtcMsgClient;
        this.signalingParameters = new IAppRTCClient.SignalingParameters(iceServerList, initiator);
        this.Uid = uid;
    }

    public static Builder builder(){
        return new Builder();
    }

    public static class Builder{

        private boolean initiator;
        private boolean videoEnable = true;
        private boolean audioEnable = true;
        private String Uid;
        private List<PeerConnection.IceServer> iceServerList;
        private IRTCMsgClient rtcMsgClient;

        private Builder(){

        }

        public Builder setInitiator(boolean initiator){
            this.initiator = initiator;
            return this;
        }

        public Builder setVideoEnable(boolean videoEnable){
            this.videoEnable = videoEnable;
            return this;
        }

        public Builder setAudioEnable(boolean audioEnable){
            this.audioEnable = audioEnable;
            return this;
        }

        public Builder setRtcMsgClient(IRTCMsgClient client){
            rtcMsgClient = client;
            return this;
        }

        public Builder setUid(String uid){
            this.Uid = uid;
            return this;
        }

        public Builder setIceServerList(List<PeerConnection.IceServer> iceServerList){
            this.iceServerList = iceServerList;
            return this;
        }

        public Options createOptions(){
            if(rtcMsgClient == null){
                throw new RuntimeException("rtcMsgClient must be assigned");
            }
            Options options = new Options(initiator, videoEnable, audioEnable, Uid, iceServerList, rtcMsgClient);
            return options;
        }
    }
}
